<extend name="Home@Base/common" />
<block name="body">
  <div class="span9 page_message">
    <section id="contents"> 
      <include file="Home@Addons/_nav" /> 
      <if condition="$add_button || $del_button || $search_button || !empty($top_more_button)">   
      <div class="table-bar">
        <div class="fl">
         
			<div class="tools">
				<if condition="$add_button"><php> $add_url || $add_url = U('add?model='.$model['id'], $get_param);</php><a class="btn" href="{$add_url}">新 增</a></if>
				<if condition="$del_button"><php> $del_url || $del_url = U('del?model='.$model['id'], $get_param);</php><button class="btn ajax-post confirm" target-form="ids" url="{$del_url}">删 除</button></if>    
                <a class="btn" href="{$export_url}">导出数据</a>
                <volist name="top_more_button" id="vo">
                <if condition="isset($vo['is_buttion']) and $vo['is_buttion']">
                <button class="btn {$vo.class}" target-form="ids" url="{$vo.url}">{$vo.title}</button>
                <else />
                <a class="btn" href="{$vo.url}">{$vo.title}</a>
                </if>
                &nbsp;
                </volist>            
			</div>
			
			&nbsp;&nbsp;消费门店：
              <select name="pay_shop" style="padding:3px 4px; margin-bottom:5px; width:120px" >
              	<option value="-1" <php>if($pay_shop==-1)echo 'selected=selected';</php>>全部门店</option>
              	<option value="0" <php>if($pay_shop==0)echo 'selected=selected';</php>>商户总部</option>
              	<notempty name='shop'>
              		<volist name='shop' key='k' id='s'>
              			<option value="{$key}" <php>if($pay_shop==$key)echo 'selected=selected';</php>>{$s}</option>
              
              		</volist>
              	</notempty>
              </select>
              	&nbsp;&nbsp;消费金额：<input type='text' name ='minVal' value="{:I('min_value')}" style='width: 50px;'/> ~ <input type='text' name ='maxVal' value="{:I('max_value')}" style='width: 50px;'/> &nbsp;<a href='javascript:;' class='btn' id='priceSearch' style='margin-top: -9px;'>查询</a>
      
     &nbsp;&nbsp;  消费时间<input type="datetime" placeholder="请选择消费日期" value="{:I('start_ctime')}" class="text date" name="start_ctime" style="width: 130px;">
            至
            <input type="datetime" placeholder="请选择消费日期" value="{:I('end_ctime')}" class="text date" name="end_ctime" style="width: 130px;">
         &nbsp;<a href='javascript:;' class='btn' id='ctimeSearch' style='margin-top: -9px;'>查询</a>
      
        
        </div>
        <!-- 高级搜索 -->
        <if condition="$search_button">
        <div class="search-form fr cf">
        
       
         
          <div class="sleft">
            <php> $get_param['model']=$model['name']; $search_url || $search_url = addons_url(MODULE_NAME.'://'.CONTROLLER_NAME.'/lists', $get_param);</php>
            <php>empty($search_key) && isset($model['search_key']) && $search_key=$model['search_key'];empty($search_key) && $search_key='title';</php>
            <input type="text" name="{$search_key}" class="search-input" value="{:I($search_key)}" placeholder="{$placeholder}">
            <a class="sch-btn" href="javascript:;" id="search" url="{$search_url}"><i class="btn-search"></i></a> </div>
        </div>
        </if>
        <!-- 多维过滤 -->
        <notempty name="muti_search">
        <form class="muti_search cf">
          <div class="" style="line-height: 30px;">
          <volist name='muti_search' id='vo'>
          <switch name="vo.type">
                <case value="select">
                    <span>{$vo.title}：</span>
                    <select name="{$vo.name}" class="search-input input-small">
                    <volist name='vo.options' id='option'>
                    <option value="{$option.value}" <eq name='option.default_value' value='option.value'>selected</eq> >{$option.title}</option>
                    </volist>                    
                    </select>
                </case>
                <case value="datetime">
                    <span>{$vo.title}：</span>
             <input type="datetime" name="start_time" class="search-input date input-small" value="{$vo.start_time}" placeholder="请选择时间">
             <span>至</span>
             <input type="datetime" name="end_time" class="search-input date input-small" value="{$vo.end_time}" placeholder="请选择时间">
                </case>
                <case value="checkbox">
                    <span>{$vo.title}：</span>
                    <volist name='vo.options' id='option'>
                    <input type="checkbox" name="{$option.name}" class="" value="{$option.value}" <eq name='option.default_value' value='option.value'>checked</eq> >{$option.title}
                    </volist>
                </case>
                <case value="radio">
                    <span>{$vo.title}：</span>
                    <volist name='vo.options' id='option'>
                    <input type="radio" name="{$option.name}" class="" value="{$option.value}" <eq name='option.default_value' value='option.value'>checked</eq> >{$option.title}
                    </volist>
                </case>
                  
             
            </switch>
            </volist>
             
             <!-- <a class="sort " href="#" title="排序">排序:高->低</a> -->
             <button type="button" class="sch-btn btn" href="javascript:;" id="search">搜索</button> </div>
        </form>
        </notempty>
      </div>
      </if>
      <!-- 数据列表 -->
      <div class="data-table">
        <div class="table-striped">
          <table cellspacing="1">
            <!-- 表头 -->
            <thead>
              <tr>
                <if condition="$check_all"><th class="row-selected row-selected"> <input type="checkbox" id="checkAll" class="check-all regular-checkbox"><label for="checkAll"></label></th></if>
                <volist name="list_grids" id="field">
                  <th <notempty name="field.width">style="width:{$field.width}px"</notempty> >{$field.title}</th>
                </volist>
              </tr>
            </thead>
            
            <!-- 列表 -->
            <tbody>
              <volist name="list_data" id="data">
                <tr>
                  <if condition="$check_all"><td><input class="ids regular-checkbox" type="checkbox" value="{$data['id']}" name="ids[]" id="check_{$data['id']}"><label for="check_{$data['id']}"></label></td></if>
                  <volist name="list_grids" id="grid">
                    <td>{$data[$key]}</td>
                  </volist>
                </tr>
              </volist>
            </tbody>
          </table>
        </div>
      </div>
      <div class="page"> {$_page|default=''} </div>
    </section>
  </div>
</block>
<block name="script"> 
   <link href="__STATIC__/datetimepicker/css/datetimepicker_blue.css?v={:SITE_VERSION}" rel="stylesheet" type="text/css">
    '; </php>
  <link href="__STATIC__/datetimepicker/css/dropdown.css?v={:SITE_VERSION}" rel="stylesheet" type="text/css">
  <script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script> 
  <script type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js?v={:SITE_VERSION}" charset="UTF-8"></script> 

  <script type="text/javascript">
$(function(){
	$('.time').datetimepicker({
        format: 'yyyy-mm-dd hh:ii',
        language:"zh-CN",
        minView:0,
        autoclose:true
    });
    $('.date').datetimepicker({
        format: 'yyyy-mm-dd',
        language:"zh-CN",
        minView:2,
        autoclose:true
    });	
    
	//搜索功能
	$("#search").click(function(){
		var url = $(this).attr('url');
        var query  = $('.search-form').find('input').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
        query = query.replace(/^&/g,'');
        if( url.indexOf('?')>0 ){
            url += '&' + query;
        }else{
            url += '?' + query;
        }
        if(query == '' ){
        	var addon="{MODULE_NAME}";
        	if(addon){
        		url="{:addons_url(MODULE_NAME.'://'.CONTROLLER_NAME.'/buy_lists')}";
        	}
        }
		window.location.href = url;
	});

    //回车自动提交
    $('.search-form').find('input').keyup(function(event){
        if(event.keyCode===13){
            $("#search").click();
        }
    });
    
    $("select[name='pay_shop']").change(function(){
		var url = "{:addons_url(MODULE_NAME.'://'.CONTROLLER_NAME.'/buy_lists')}&pay_shop="+$(this).val();
		
        var query  = $('.type-form').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
        query = query.replace(/^&/g,'');
        if( url.indexOf('?')>0 ){
            url += '&' + query;
        }else{
            url += '?' + query;
        }
		window.location.href = url;
	});
    $('#priceSearch').click(function(){
		var min =$("input[name='minVal']").val();
		var max =$("input[name='maxVal']").val();
		var url="{:addons_url(MODULE_NAME.'://'.CONTROLLER_NAME.'/buy_lists')}&is_recharge=1&min_value="+min+"&max_value="+max;
		location.href=url;
	});
    $('#ctimeSearch').click(function(){
		var start =$("input[name='start_ctime']").val();
		var end =$("input[name='end_ctime']").val();
		if(start || end){
			var url="{:addons_url(MODULE_NAME.'://'.CONTROLLER_NAME.'/buy_lists')}&is_ctime=1&start_ctime="+start+"&end_ctime="+end;
			location.href=url;
		}
		
	});

})
</script> 
</block>
